#include <chrono>
#include <rclcpp/rclcpp.hpp>

using namespace std::chrono_literals;

class Timer {
public:
  Timer() {
    // node_ = rclcpp::Node::make_shared("timer_node");
    // timer_ = node_->create_wall_timer(std::chrono::milliseconds(1000),
    //                                   std::bind(&Timer::timer_callback,
    //                                   this));
  }
  void setTimer(const rclcpp::TimerBase::SharedPtr &timer) { timer_ = timer; }
  ~Timer() {}

  void timer_callback(int id) {
    // RCLCPP_INFO(rclcpp::get_logger("timer1_node"), "Timer callback called");
    std::cout << "Timer callback called   " << id << std::endl;
  }

private:
  rclcpp::TimerBase::SharedPtr timer_;
  //   rclcpp::Node::SharedPtr node_;
};

class TimerNode : public rclcpp::Node {
public:
  TimerNode() : Node("create_timer_node") {}
  void setup() {
    timer_.setTimer(
        create_wall_timer(1s, [this]() { timer_.timer_callback(1); }));
    timer2_.setTimer(
        create_wall_timer(2s, [this]() { timer2_.timer_callback(2); }));
  }

private:
  Timer timer_;
  Timer timer2_;
};

int main(int argc, char *argv[]) {
  rclcpp::init(argc, argv);
  auto node = std::make_shared<TimerNode>();
  node->setup();
  rclcpp::spin(node);
  rclcpp::shutdown();
  return 0;
}